const Koa = require('koa')
const koaBody = require('koa-body')
const cors = require('koa2-cors')
// 导入路由
const usersRouter = require('../router/users.route')
const testRouter = require('../router/test.route')
// 导入统一错误处理
const errHandle = require('./errHandle')
const app = new Koa()
app.use(cors())
app.use(koaBody({ multipart: true })) // 识别form-data
app.use(usersRouter.routes())
app.use(testRouter.routes())


// 统一处理错误
app.on('error', errHandle)
module.exports = app